<template>
  <div class="tour-container">
    <div class="top">
      <p class="title">实时游客统计</p>
      <p class="bg-img"></p>
      <p class="total">可预约总量<span>9999</span>人</p>
    </div>
    <div class="center">
      <span v-for="(item, index) in perNum" :key="index">{{ item }}</span>
    </div>
    <div ref="echart" class="echart-box">图表</div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
import "echarts-liquidfill";
// 总人数
const perNum = ref("215908人");
// 图表容器
const echart = ref();
onMounted(() => {
  // 获取echarts实例
  var myChart = echarts.init(echart.value);
  // 绘制图表
  myChart.setOption({
    // title: {
    //   // 标题
    //   text: "水球图",
    //   textStyle: {
    //     color: 'white'
    //   }
    // },
    series: [
      // 系列：决定你展示什么样的图形图表
      {
        type: "liquidFill", // 系列
        data: [0.6, 0.4, 0.2], // 展示的数据(由大到小)
        waveAnimation: true, // 动画
        animationDuration: 3,
        animationDurationUpdate: 0,
        radius: "92%", // 半径
        outline: {
          show: true,
          borderDistance: 8,
          itemStyle: {
            color: "lightblue",
            borderColor: "#294D99",
            borderWidth: 8,
            shadowBlur: 20,
            shadowColor: "rgba(0, 0, 0, 0.25)",
          },
        },
      },
    ],
    grid: {
      // 布局
      height: "240px",
    },
  });
});
</script>

<style scoped lang="scss">
// 父元素已开启了flex布局
.tour-container {
  flex: 1.2;
  background: url("../../images/dataScreen-main-lt.png");
  background-size: 100% 100%;
  margin-top: 14px;
  .top {
    .title {
      color: white;
      font-size: 20px;
    }
    .bg-img {
      width: 68px;
      height: 10px;
      background: url("../../images/dataScreen-title.png");
      background-size: 100% 100%;
      margin-top: 10px;
    }
    .total {
      float: right;
      color: white;
      font-size: 20px;
      span {
        color: lightgreen;
      }
    }
  }
  .center {
    margin-top: 30px;
    color: #29fcff;
    display: flex;
    padding: 10px;
    span {
      flex: 1;
      background: url(../../images/total.png) no-repeat;
      background-size: 100% 100%;
      height: 50px;
      line-height: 50px;
      text-align: center;
      font-size: 24px;
    }
  }
  .echart-box {
    width: 100%;
    height: 240px;
  }
}
</style>
